<?php
namespace news\Controller;
use Common\Model\SlideModel;
use News\Controller\CommonController;
use Common\Model\NewsModel;
use Common\Model\NewsCategoryModel;

class IndexController extends CommonController {
    public function index(){
        $model = new NewsModel;
        //最新
        $cateModel = new NewsCategoryModel();
        $cate = $cateModel->getTopCategoryList();
        foreach($cate as $k => $v){
            if(!$v['cid']) continue;
            $cate[$k]['news'] = $model->getNewsById($v['cid'],10);
        }
        //轮播内容
        $slider = $model->getSliderData();
        //广告轮播内容
        $sliderModel = new SlideModel();
        $adSlider = $sliderModel->getSliderByType(2);
        $this->assign('cate',$cate)->assign('adSlider',$adSlider);
        $new = $model->getNew();
        $this->assign('new',$new)->assign('slider',$slider);
        $this->display('/news/index');
    }
}